<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/common/cm.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="${ctx}/js/lib/zTree/css/zTreeStyle/zTreeStyle.css" type="text/css">
<link rel="stylesheet" href="${ctx}/js/lib/css/zTree/zTreeStyle/css/zTreeStyle.css" type="text/css">
	<script type="text/javascript" src="${ctx}/js/lib/zTree/js/jquery.ztree.core-3.5.js"></script>
	<script type="text/javascript" src="${ctx}/js/lib/zTree/js/jquery.ztree.excheck-3.5.js"></script>
<script src="${ctx}/js/pub/sysmgr_auth.js" type="text/javascript"></script>
<script type="text/javascript">
	$(function() {
		$("#inputForm").checkForm(changeDisableChekBox);
		$.reloadResource();
	});
	function changeDisableChekBox(){
		$(":checkbox[name='rids'][default='false']:checked:disabled").each(function(){
    		$(this).removeAttr("disabled","");
    	});
		
	}
	var setting = {
			view: {
				selectedMulti: false
			},
			check: {
				enable: false
			},
			data: {
				simpleData: {
					enable: true
				}
			}
		};
	var zNodes = "";
	var zTree;
	function loadTree(){
		$.fn.zTree.init($("#treeDemo"), setting, zNodes);
		zTree = $.fn.zTree.getZTreeObj("treeDemo");
	}
    
	$(document).ready(function() {
		$("#div1").css({"left":$("#tab1").width()+60,"position": "absolute","width":"350px","float": "right"});
	});
</script>
<style type="text/css">
div.zTreeDemoBackground {width:350px;height:340px;text-align:left;}
ul.ztree {margin-top: 10px;width:300px;height:320px;overflow-y:scroll;overflow-x:auto;}
</style>
</head>
<body>
	<div class="wrap"  >
		<div class="location">
			<font class="red home_icons">当前位置：</font>${navigation}
		</div>
	<div style="height:90%; overflow-y:auto;">
	<form action="${ctx}/pub/sysmgr/assign_user_role.do" method="post" id="inputForm">
		<div class="addbtn_bg" >
				<div class="li">
					<input type="submit" value="提交" class="addbtn" />
				</div>
				<div class="li">
					<input name="" type="button" class="addbtn" value="返回"
						onclick="javascript:history.back(-1);" />
				</div>
			</div>
	<div style="padding-left: 10px;">
	<table width="400px" border="0" align="left" cellpadding="0" id="tab1"
					cellspacing="0" class="table_sty">
		<tbody>
			<input type="hidden" name="backurl" value="${backurl}" />
			<input type="hidden" name="userId" value="${param.userId}" />
			<tr>
				<td width="36%" class="td_right">*选择角色：</td>
				<td class="td_default">
				<c:forEach var="r" items="${roles}"  varStatus="idx">
				   <c:set var="checked" value="${r.checked eq 'true'? 'checked':'' }"></c:set>
				  <c:set var="checked" value="${r.isDefault eq '1'? 'checked':checked }"></c:set>
				   <c:set var="default" value="${r.isDefault eq '1'? 'true':'false' }"></c:set>
				   <c:set var="disabled" value="${(r.roleStatus eq '0' ||r.isDefault eq '1')? 'disabled':'' }"></c:set>
				   <input type="checkbox" value="${r.id}" name="rids" onclick="$.reloadResource();" 
				   ${checked} default='${default}'
				   datatype="group" ${disabled}
				   msg="请选择角色！"
				   /> 
				   <c:out value="${r.roleName}" />
				   <c:if test="${r.roleStatus eq '0' }">
				    <span class="requiredField">(${cm:statusStr(r.roleStatus)})</span>
				   </c:if>
				    <c:if test="${r.isDefault eq '1' }">
				    <span class="requiredField">(公共角色)</span>
				   </c:if>
				 </c:forEach>
				 <label id="success_rids"  style="display:none;"><span class="ico_cue_ok"></span></label>
					<label class="error_rids" style="display:none;" for="rids"><span class="ico_cue_no"></span>
					<span class="alert-error" id="error_rids"></span></label>
				</td>
			</tr>
		</tbody>
		</table>
		</div>
		<div id="div1" class="right"  >
				 所选角色资源权限合集如下：
				 <div class="zTreeDemoBackground">
		               <ul id="treeDemo" class="ztree"></ul>
		         </div>
		</div>
	</form>
	</div>
	</div>
</body>
</html>
